<template>
  <div id="login">
    <div>
      <div>账号：<input type="text" v-model.trim="username" /></div>
      <div>密码：<input type="text" v-model.trim="password" /></div>
      <div>
        <span @click="login">登录</span> <span @click="reset">重置</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  components: {},
  data() {
    return {
      username: '',
      password: '',
    }
  },
  methods: {
    reset() {
      ;(this.username = ''), (this.password = '')
    },
    login() {
      if (this.username == 'zy' && this.password == '123123aabb') {
        localStorage.setItem('token', 'Bearer xxx')
        this.$router.replace('/home')
      } else {
        alert('账号密码错误')
        this.username = ''
        this.password = ''
      }
    },
  },
}
</script>

<style lang="less"></style>
